package gupao.design.factory.simplefactory;

import gupao.design.factory.ICourse;

/**
 * @author: liuchenhui
 * @create: 2019-04-14 14:07
 **/
public class CourseFactory {
//    public ICourse create(String name) {
//        if ("java".equals(name)) {
//            return new JavaCourse();
//        } else
//            return null;
//    }

    public ICourse create(Class clzz) {
        try {
            if (clzz != null)
                return (ICourse) clzz.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
}
